package main

import (
	"fmt"
	"gitlab.sensechar.com/kafkaGo/config"
	"strconv"
	"time"

	"gitlab.sensechar.com/kafkaGo/pkg/client"
)

func main() {
	option := config.NewOption("./config/config.yaml")
	kafkClient := client.NewSynKafkaClient(option)

	for i := 0; i < 10; i++ {
		time.Sleep(1 * time.Second)
		err := kafkClient.BathSysPublish(client.KafkaMessage{
			Messages: client.Message{
				Data: map[string]interface{}{
					"sync": i,
				},
				Timestamp: i,
			},
			Key:    strconv.Itoa(i),
			Topic: "kafka-go-topic",
		})
		if err != nil {
			fmt.Println("message send err:", err)
		}
		fmt.Println("message send sucess")
	}

	defer kafkClient.SysClose()
}

// 消费者与消费者组 https://blog.csdn.net/gdkyxy2013/article/details/86644919